<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
    <script src="https://lib.baomitu.com/axios/0.19.2/axios.js"></script>
</head>
<body>
<div id="app">
    <input type="text" v-model="uname"><br> <input
        type="text" v-model="pwd"><br>
    <button @click="login()">login</button>
</div>
<script type="text/javascript">
    new Vue({
        el:"#app",
        data:{
            uname:"",
            pwd:""
        },
        methods:{
            login:function(){
                var params=new URLSearchParams();
                params.append("account",this.uname);
                params.append("pwd",this.pwd);
                axios.post("/auth/login",params)
                    .then(res =>{
                        console.log(res.data);
                        if(res.data.code==200){
                            //在当前浏览器所有页面都可以获取storage;
                            var storage=window.localStorage;
                            //清空storage中的数据
                            storage.clear();
                            //存放数据
                            storage.setItem("token",res.data.token);
                            storage.setItem("refreshToken",res.data.refreshToken);
                            window.location.href="index.html";
                        }
                    })
            }
        }

    })
</script>
</body>
</html>